<template>
	<view class="content-header-f">
		<view class="header">
			<view class="top66"></view>
			<view class="header-txt">
				忘记密码
			</view>
			<view class="header-txt1">
				请输入手机号码和验证码找回密码
			</view>
			<view class="flex-column">
				<view class="top100"></view>
				<view class="detal-body flex-row flex-content-start">
					<input class="input" v-model="from.mobile" placeholder="请输入手机号" placeholder-class="input-p"/>
				</view>
				<view class="detal-body flex-row flex-content-start">
					<input class="input" v-model="from.newpassword" type="password" placeholder="请输入新密码" placeholder-class="input-p"/>
				</view>
				<view class="detal-body-1 flex-row flex-content-between">
					<view class="code-body">
						<input class="input" v-model="from.captcha" placeholder="请输入验证码" placeholder-class="input-p"/>
					</view>
					<view class="hq" @tap="getCode">{{codeTxt}}</view>
				</view>
				<view class="flex-row flex-content-center">
					<view class="queren" @tap="resetPwd">确认</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				codeTxt:"获取",
				from:{//提交数据
					mobile:"",
					newpassword:"",
					captcha:"",
					type:"mobile"
				}
			}
		},
		methods:{
			//获取手机验证码
			getCode(){
				if(this.codeTxt=="获取"){
					let from = this.from;
					if(!from.mobile){
						this.$utils.showMessage("请输入手机号码")
						return
					}
					let that = this;
					let data = {
						mobile:from.mobile,
						event:'resetpwd'
					}
					// console.log(data);
					this.$api.getMobileCode(data).then(res=>{
						that.$utils.countdown((time)=>{
							if(time==0){
								that.codeTxt = '获取'
							}else{
								that.codeTxt = time+"秒"
							}
						})
					})
				}
			},
			resetPwd(){
				let that = this
				let from = this.from;
				if(!from.mobile){
					this.$utils.showMessage("请输入手机号码")
					return
				}
				if(!from.newpassword){
					this.$utils.showMessage("请输入新密码")
					return
				}
				if(!from.captcha){
					this.$utils.showMessage("请输入验证码")
					return
				}
				this.$api.resetPwd(from).then(res=>{
					that.$utils.showMessage("修改成功",()=>{
						uni.navigateBack();
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	.queren{
		width: 690rpx;
		height: 96rpx;
		background: $default-button-color;
		border-radius: 48rpx 48rpx 48rpx 48rpx;
		opacity: 1;
		font-size: 32rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: $default-button-foncolor;
		text-align: center;
		line-height: 96rpx;
		margin-top: 44rpx;
	}
	.code-body{
		width: 499rpx;
		height: 96rpx;
		background: #F5F5F5;
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		opacity: 1;
	}
	.hq{
		width: 161rpx;
		height: 96rpx;
		background: $default-button-color;
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		opacity: 1;
		font-size: 30rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: $default-button-foncolor;
		text-align: center;
		line-height: 96rpx;
	}
	.input{
		height: 50rpx;
		padding: 23rpx 50rpx 28rpx 50rpx;
		
	}
	.input-p{
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
	}
	.top100{
		width: 100%;
		height: 100rpx;
	}
	.detal-body{
		width: 690rpx;
		height: 96rpx;
		background: #F5F5F5;
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		opacity: 1;
		margin-bottom: 36rpx;
		// margin-top: 36rpx;
	}
	.detal-body-1{
		width: 690rpx;
		height: 96rpx;
		// background: #F5F5F5;
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		opacity: 1;
		margin-bottom: 36rpx;
	}
	.header-txt1{
		font-size: 30rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		margin-top: 20rpx;
	}
	.top66{
		width: 100%;
		height: 66rpx;
	}
	.header-txt{
		font-size: 40rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #333333;
	}
	.header{
		width: 690rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
	}
</style>